/**   中间件实例2：
 *        变量传递
 * */
var express = require('express');
var app = new express()


var requestDate= function (req,res,next) {

    var currentDate = new Date();
    req.requestDate = currentDate.getFullYear()+"/" + (currentDate.getMonth()+1)+
        "/"+currentDate.getDate();

    next();

}


app.use(requestDate);// 注册中间件


app.get('/test',function (req,res) {
    res.send('test on ' + req.requestDate);
})


app.get('/list',function (req,res) {
    res.send('list on ' + req.requestDate);
})


var server  =app.listen(3000,'localhost',function () {
    var host = server.address().address;
    var port= server.address().port;

    console.log("the server is running on http:// %s:%s",host,port);
})